<template>
  <br />
  &emsp;
  <div style="font-size: 22px">
    淘汰日期：<el-date-picker style="width: 100px" v-model="form.start">
    </el-date-picker
    ><el-date-picker style="width: 100px" v-model="form.end"> </el-date-picker
    >&emsp;&emsp; 羊只耳号：<el-select
      style="width: 100px"
      placeholder="请选择"
      v-model="form.sleepInforId"
    >
      <el-option
        v-for="item in SelectEar"
        :label="item.earNumber"
        :value="item.sleepInforId"
      />
    </el-select>
    &nbsp;&nbsp; 淘汰原因：<el-select
      style="width: 100px"
      v-model="form.culledId"
    >
      <el-option
        :label="item.culledName"
        :value="item.culledId"
        v-for="item in cull"
      />
    </el-select>
    &nbsp;&nbsp; 是否离场：<el-select
      style="width: 100px"
      v-model="form.exitName"
    >
      <el-option label="已离场" value="0" />
      <el-option label="在场" value="1" />
    </el-select>
    &emsp;&emsp;
    <el-button type="danger" size="large" @click="gettableData()"
      >查询</el-button
    >
  </div>
  <br />
  <hr style="font-size: 20px" />
  <br />

  <el-table height="400" border style="width: 100%" :data="tableData">
    <el-table-column type="selection" />
    <el-table-column prop="sheepCulledId" label="序号" />
    <el-table-column prop="culledDate" label="淘汰日期">
      <template v-slot="scope">
        <span>{{ scope.row.culledDate.replace('T', ' ') }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="earNumber" label="羊只耳号" />
    <el-table-column prop="culledName" label="淘汰原因"> </el-table-column>
    <el-table-column prop="exitName" label="是否离场">
      <template v-slot="scope">
        <span v-if="scope.row.exitName == 0">已离场</span>
        <span v-if="scope.row.exitName == 1">在场</span>
      </template>
    </el-table-column>
    <el-table-column prop="measures" label="处理措施"> </el-table-column>
    <el-table-column prop="varietyName" label="品种"> </el-table-column>
    <el-table-column prop="gender" label="性别">
      <template v-slot="scope">
        <span v-if="scope.row.gender == 1">公</span>
        <span v-if="scope.row.gender == 2">母</span>
      </template>
    </el-table-column>
    <el-table-column prop="breedStatuId" label="繁殖状态" />
    <el-table-column label="淘汰月龄">
      <template v-slot="scope">
        <span>{{ scope.row.ageDay / 30 }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="ageDay" label="淘汰日龄"> </el-table-column>
    <el-table-column prop="cottageName" label="淘汰栋舍" />
    <el-table-column prop="fieIdName" label="淘汰栏位" />
    <el-table-column prop="sleepBirthDate" label="出生日期">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.sleepBirthDate.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="createId" label="创建人" />
    <el-table-column prop="createTime" label="创建时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.createTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="updateId" label="修改人" />
    <el-table-column prop="updateTime" label="修改时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.updateTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="examId" label="复核人" />
    <el-table-column prop="examTime" label="复核时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.examTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="documentNum" label="单据号" />
    <el-table-column prop="name" fixed="right" width="120" label="操作">
      <template #default="scope"> </template>
    </el-table-column>
  </el-table>
</template>

<script setup lang="ts">
import {
  Check,
  Delete,
  Edit,
  Message,
  Back,
  Plus,
  Setting,
  SuccessFilled,
  Minus,
  Close
} from '@element-plus/icons-vue';
import { reactive, ref, onMounted, computed } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useCounterStore } from '@/stores/counter';

const counterStore = useCounterStore();
const route = useRoute();
const router = useRouter();

onMounted(() => {
  geteweData();
  getcull();
  gettableData();
});

//获取耳号
const SelectEar = ref<any>([]);
const geteweData = () => {
  axios.get('http://localhost:5039/api/SleepBegin/SelectEar').then((res) => {
    SelectEar.value = res.data.item;
  });
};

//淘汰原因
const cull: any = ref([]);

const getcull = () => {
  axios.post('http://localhost:5039/api/Raise/Handle1').then((res) => {
    cull.value = res.data.data;
  });
};

const form = reactive({
  start: '',
  end: '',
  sleepInforId: '',
  culledId: '',
  exitName: ''
});

const tableData: any = ref([]);
const now = new Date();
const gettableData = () => {
  axios
    .post('http://localhost:5039/api/Raise/Handle/EliminateSelect', {
      start: form.start || '',
      end: form.end || '',
      sleepInforId: form.sleepInforId || 0,
      culledId: form.culledId || 0,
      exitName: form.exitName || 0
    })
    .then((res) => {
      tableData.value = res.data.data;
    });
};
</script>

<style scoped></style>
